/**
 * iWeb2GooglePages - Converts export iWeb content and uploads it to GPs.
 * Copyright (C) 2008 Will Droste
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */
package org.iweb2gps;

import java.io.File;
import java.text.MessageFormat;

public class Main {
    /**
     * Should be only two arguments both directories..
     * 
     * @param args
     */
    public static void main(String[] args) throws Exception {
        if (args.length != 2) {
            final String msg = "Usage: Main <src> <dest>";
            throw new IllegalArgumentException(msg);
        }
        // get the directory..
        File src = new File(args[0]);
        if (!src.isDirectory()) {
            final String msg = "Source directory does not exist!";
            throw new IllegalArgumentException(msg);
        }
        // check the destination directory..
        File dest = new File(args[1]);
        dest.mkdirs();
        IWebConverter converter = new IWebConverter(src, dest);
        converter.addListener(new IWebConverter.Listener() {
            final String TEMPLATE = "Process {0} of {1}: {2}";

            public void processing(int idx, int total, File f) {
                System.out.println(MessageFormat
                        .format(TEMPLATE, idx, total, f));
            }
        });
        converter.convert();
    }
}
